package org.xiyu.yee.beacon_anti_phantom.event;

import net.minecraft.server.level.ServerLevel;
import org.xiyu.yee.beacon_anti_phantom.beacon.BeaconManager;
import org.xiyu.yee.beacon_anti_phantom.particle.ParticleManager;

public class ServerEventHandler {
    private static ServerEventHandler instance;
    private int tickCounter = 0;
    
    private ServerEventHandler() {}
    
    public static ServerEventHandler getInstance() {
        if (instance == null) {
            instance = new ServerEventHandler();
        }
        return instance;
    }
    
    /**
     * 服务器tick事件处理
     */
    public void onServerTick(ServerLevel level) {
        tickCounter++;
        
        // 每100tick（5秒）更新一次信标状态
        if (tickCounter % 100 == 0) {
            BeaconManager.getInstance().updateBeacons(level);
        }
        
        // 处理粒子效果（信标保护范围圆圈）
        ParticleManager.getInstance().tick(level);
        
        // 幻翼攻击效果现在在ServerChunkCacheMixin中处理
    }
    
    /**
     * 服务器启动事件处理
     */
    public void onServerStarted() {
        // 初始化配置等
    }
}
